package Server.Model.Hall;

import java.util.HashMap;
import java.util.List;

import org.apache.commons.lang.StringUtils;

import Server.Model.Base.SHMUser;
import common.routine.JsonUtils;
import net.sf.json.JSONObject;
import rank.RankDef;
import rank.RankRichDef;
import redis.protocal.DbInfoMgr;

public class CMD_Hall {

}
class CMD_Request_GPS {
	String getJsonData() {
		JSONObject root = new JSONObject();
		root.put("command", "Hall_Request_Gps");
		return root.toString();
	}
};
class CMD_S_CreateRoom {
	int uid;
	int cbResult;
	String room_type;

	String getJsonData() {
		JSONObject root = new JSONObject();
		root.put("command", "hall_create_room");
		root.put("uid", uid);
		root.put("cbResult", cbResult);
		return root.toString();
	}
};

class CMD_S_JoinRoom {
	int uid;
	int cbResult;
	String room_type;
	int room_id;

	String getJsonData() {
		JSONObject root = new JSONObject();
		root.put("command", "hall_join_room");
		root.put("uid", uid);
		root.put("cbResult", cbResult);
		root.put("room_type", room_type);
		root.put("room_id", room_id);
		return root.toString();
	}
};
class CMD_S_DissmissRoom {
	int uid;
	int cbResult;
	int room_id;

	String getJsonData() {
		JSONObject root = new JSONObject();
		root.put("command", "hall_dismiss_room");
		root.put("uid", uid);
		root.put("cbResult", cbResult);
		root.put("room_id", room_id);
		return root.toString();
	}
};
class CMD_S_HALL_NEED_LOGOUT {
	String reason;

	String getJsonData() {
		JSONObject root = new JSONObject();
		root.put("command", "hall_need_logout");
		root.put("reason", reason);
		return root.toString();
	}
};
class CMD_S_UserRoom {
	int uid;
	int room_id;

	String getJsonData() {
		JSONObject root = new JSONObject();
		root.put("command", "hall_user_room");
		root.put("uid", uid);
		root.put("room_id", room_id);
		return root.toString();
	}
};

/***
 * 登陆成功
 */

class CMD_LoginSuccess {
	SHMUser m_objUser;
	String userIcon;
	void setUser(SHMUser data) {
		m_objUser = data;
	}

	String getJsonData() {
		String strObjUser = m_objUser.getJsonData();
		JSONObject objUser = JSONObject.fromObject(strObjUser);
		JSONObject root = new JSONObject();
		root.put("command", "hall_login");
		root.put("m_objUser", objUser);
		root.put("sUserIcon", userIcon);
		return root.toString();
	}
};

class CMD_WXLoginSuccess {
	SHMUser m_objUser;
	String userIcon;
	String loginType;

	void setUser(SHMUser data) {
		m_objUser = data;
	}

	String getJsonData() {
		String strObjUser = m_objUser.getJsonData();
		if(m_objUser.m_lUid == 0){
			int a = 0;
			int b = a;
		}
		JSONObject objUser = JSONObject.fromObject(strObjUser);
		JSONObject root = new JSONObject();
		root.put("command", "hall_wxlogin");
		root.put("m_objUser", objUser);
		root.put("sUserIcon", userIcon);
		root.put("type", loginType);
		return root.toString();
	}
};

class CMD_LoginFailed {
	Integer m_iErrorType; // 类似
	String m_sErrorMsg; // 秘密

	String getJsonData() {
		JSONObject root = new JSONObject();
		root.put("command", "hall_login_failed");
		root.put("errtype", m_iErrorType);
		root.put("errmsg", m_sErrorMsg);
		return root.toString();
	}
};

class CMD_S_ShareTimeLine {
	Long m_lUid;// 哪个玩家ID获得
	Long m_lTotalGem;
	Long m_lTotalCoin;
	String getJsonData() {

		JSONObject root = new JSONObject();
		root.put("command", "hall_share_timeline");
		root.put("m_lUid", m_lUid);
		root.put("m_lTotalGem", m_lTotalGem);
		root.put("m_lTotalCoin", m_lTotalCoin);
		return root.toString();

	}
};
class CMD_S_ZhuanPan {
	int m_lUid;// 哪个玩家ID获得
	int m_lTotalGem;
	int m_lRotateToGeZi;
	int m_lAddGem;
	String getJsonData() {
		JSONObject root = new JSONObject();
		root.put("command", "hall_zhuanpan");
		root.put("m_lUid", m_lUid);
		root.put("m_lTotalGem", m_lTotalGem);
		root.put("m_lRotateToGeZi", m_lRotateToGeZi);
		root.put("m_lAddGem", m_lAddGem);
		return root.toString();
	}
};
class CMD_S_DuiHuan {
	int m_lUid;// 哪个玩家ID获得
	int cbResult;// 哪个玩家ID获得
	int m_lTotalGem;
	int m_lTotalCoin;

	String getJsonData() {

		JSONObject root = new JSONObject();
		root.put("command", "hall_duihuan");
		root.put("m_lUid", m_lUid);
		root.put("cbResult", cbResult);
		root.put("m_lTotalGem", m_lTotalGem);
		root.put("m_lTotalCoin", m_lTotalCoin);
		return root.toString();

	}
};
class CMD_S_TongZhi {
	int m_lUid;// 哪个玩家ID获得
	String szContent;

	String getJsonData() {

		JSONObject root = new JSONObject();
		root.put("command", "hall_tongzhi");
		root.put("m_lUid", m_lUid);
		root.put("szContent", szContent);
		return root.toString();

	}
};

class CMD_S_Avatar {
	int m_lUid;// 哪个玩家ID获得
	String szAvatarURL;

	String getJsonData() {

		JSONObject root = new JSONObject();
		root.put("command", "hall_user_avatar");
		root.put("m_lUid", m_lUid);
		root.put("avatar_url", szAvatarURL);
		return root.toString();

	}
};

/***
 * 充值成功通知
 */
class CMD_PaySuccessNotice {
	Long m_lUid;
	int m_iVip;
	Integer m_lTotalCoin;
	Integer m_lAddCoin;

	Integer m_lTotalGem;
	Integer m_lAddGem;

	Integer m_lTotalCard;
	Integer m_lAddCard;

	
	Long m_lNobleTime;
	Long m_lAddNobleTime;

	String getJsonData() {

		JSONObject root = new JSONObject();
		root.put("command", "hall_paysuccess");
		root.put("m_lUid", m_lUid);
		root.put("m_iVipLevel", m_iVip);
		root.put("m_lTotalCoin", m_lTotalCoin);
		root.put("m_lAddCoin", m_lAddCoin);
		root.put("m_lTotalGem", m_lTotalGem);
		root.put("m_lAddGem", m_lAddGem);
		root.put("m_lTotalCard", m_lTotalCard);
		root.put("m_lAddCard", m_lAddCard);		
		root.put("m_lNobleTime", m_lNobleTime);
		root.put("m_lAddNobleTime", m_lAddNobleTime);
		return root.toString();
	}
};

class CMD_ConvertGem2CoinNotice {
	Long m_lUid;
	int m_iResult;
	Long m_lTotalCoin;
	Long m_lTotalGem;
	Long m_lAddCoin;
	Long m_lAddGem;

	String getJsonData() {

		JSONObject root = new JSONObject();
		root.put("command", "hall_convert_gem2coin");
		root.put("m_lUid", m_lUid);
		root.put("m_iResult", m_iResult);
		root.put("m_lTotalCoin", m_lTotalCoin);
		root.put("m_lAddCoin", m_lAddCoin);
		root.put("m_lTotalGem", m_lTotalGem);
		root.put("m_lAddGem", m_lAddGem);
		return root.toString();
	}
};

/***
 * 同步筹码
 */
class CMD_ChipInfo {
	Long m_lUid;
	Long m_lTotalCoin;
	Long m_lTotalGem;
	Long m_lTicket;

	String getJsonData() {

		JSONObject root = new JSONObject();
		root.put("command", "hall_chip");
		root.put("m_lUid", m_lUid);
		root.put("m_lTotalCoin", m_lTotalCoin);
		root.put("m_lTotalGem", m_lTotalGem);
		root.put("m_iTicket", m_lTicket);
		return root.toString();

	}
};
//同步代理
class CMD_DlInfo{
	int dl;
	String getJsonData(){
		JSONObject root = new JSONObject();
		root.put("command","reg_dl");
		root.put("dl",dl);
		return root.toString();
	}
	
};
class CMD_S_BindAgent {
	int cbResult;
	Long m_lUid;
	Long m_lAgentID;
	Long m_lTotalGem;
	Long m_lTotalCoin;

	String getJsonData() {
		JSONObject root = new JSONObject();
		root.put("command", "hall_bind_agent");
		root.put("cbResult", cbResult);
		root.put("m_lUid", m_lUid);
		root.put("m_lAgentID", m_lAgentID);
		root.put("m_lTotalCoin", m_lTotalCoin);
		root.put("m_lTotalGem", m_lTotalGem);
		return root.toString();
	}
};
class CMD_S_FGRoomList {
	String roomInfos[] = new String[10];
	public int AddRoomInfo(String info){
		for (int i = 0; i < roomInfos.length; i++) {
			String string = roomInfos[i];
			if (StringUtils.isEmpty(string)) {
				roomInfos[i] = info;
				return i;
			}
		}
		return -1;
	}
	String getJsonData() {
		JSONObject root = new JSONObject();
		root.put("command", "FGRoomList");
		root.put("rooms", roomInfos);
		return root.toString();
	}
};
class CMD_S_SongBi {
	int cbResult;
	int from_uid;
	int to_uid;
	int songGem;
	int songCoin;	
	int m_lFromGem;
	int m_lFromCoin;
	int m_lToGem;
	int m_lToCoin;
	
	String getJsonData() {
		JSONObject root = new JSONObject();
		root.put("command", "hall_song_bi");
		root.put("cbResult", cbResult);
		root.put("from_uid", from_uid);
		root.put("to_uid", to_uid);
		
		root.put("songGem", songGem);
		root.put("songCoin", songCoin);
		
		root.put("m_lFromGem", m_lFromGem);
		root.put("m_lFromCoin", m_lFromCoin);
		
		root.put("m_lToGem", m_lToGem);
		root.put("m_lToCoin", m_lToCoin);
		
		return root.toString();
	}
};
class CMD_Rank_Info{
	int m_uid;
	String m_nickName;
	int m_rank;
	int m_prevRank;
	int m_score;
	int m_prevScore;
	String m_headUrl;
	int m_drawed;
	public CMD_Rank_Info(){
		m_score = 0;
		m_rank = 100000;
		m_drawed = 0;
	}
	public void setRankInfo(RankDef rank){
		m_uid = rank.m_userId;
		m_nickName = rank.m_userName;
		m_rank = rank.m_rank;
		m_prevScore = rank.m_prevRank;
		m_score = rank.m_score;
		m_prevScore = rank.m_prevScore;
		m_headUrl = DbInfoMgr.getInstance().getUserAvatarUrl(m_uid);
		m_drawed = rank.m_drawed;
	}
	String getJsonData() {
		JSONObject root = new JSONObject();
		root.put("m_uid", m_uid);
		root.put("m_nickName", m_nickName);
		root.put("m_rank", m_rank);
		root.put("m_prevRank",m_prevRank);
		root.put("m_score", m_score);
		root.put("m_prevScore",m_prevScore);
		root.put("m_headUrl", m_headUrl);
		root.put("command","cmd_rank_info");
		return root.toString();
	}
}
class CMD_Rank_Rich50_Info{
	public List<String> m_topInfo;
	public String getJsonData(){
		JSONObject root = new JSONObject();
		root.put("command","hall_rank_rich50_info");
		root.put("top50",m_topInfo);
		return root.toString();
	}
}
class CMD_Rank_Top100_Info{
	List<String> m_topInfo;
	int m_fromIndex;
	int m_getNum;
	int m_prevRank;
	int m_inTopNum;
	public CMD_Rank_Top100_Info(List<String> top){
		m_topInfo = top;
		m_prevRank = 0;
	}
	public void setIndexAndNum(int from,int num){
		m_fromIndex = from;
		m_getNum = num;
	}
	public void setIsPrevRank(){
		m_prevRank = 1;
	}
	public void setTopNum(int num){
		m_inTopNum = num;
	}
	String getJsonData(){
		JSONObject root = new JSONObject();
		root.put("m_fromIndex", m_fromIndex);
		root.put("m_getNum", m_getNum);
		root.put("m_prevRank", m_prevRank);
		root.put("m_inTopNum", m_inTopNum);
		root.put("command","hall_rank_top100_info");
		
		for(int i = 0;i < m_topInfo.size();i++){
			RankDef rank = JsonUtils.deserialize(m_topInfo.get(i),RankDef.class);
			CMD_Rank_Info rankInfo = new CMD_Rank_Info();
			rankInfo.setRankInfo(rank);
			root.put("rank" + (m_fromIndex + i), rankInfo.getJsonData());
		}
		return root.toString();
	}
};
class CMD_Bind_Invitor{
	int m_invitor;
	int m_result;
	String getJsonData(){
		JSONObject root = new JSONObject();
		root.put("m_invitor", m_invitor);
		root.put("m_result", m_result);
		root.put("command","hall_bind_invitor");
		
		return root.toString();
	}
}
class CMD_GetSelf_Invitor{
	int m_invitor;
	String getJsonData(){
		JSONObject root = new JSONObject();
		root.put("m_invitor", m_invitor);		
		root.put("command","hall_user_invitor");
		
		return root.toString();
	}
}
class CMD_GetBind_Invitor{
	int m_bindId;
	String m_bindAccount;
	int m_addScore;
	int m_totalScore;
	String getJsonData(){
		JSONObject root = new JSONObject();
		root.put("m_bindId", m_bindId);
		root.put("m_bindAccount", m_bindAccount);
		root.put("m_addScore", m_addScore);
		root.put("m_totalScore", m_totalScore);
		root.put("command","hall_getbind_invitor");
		
		return root.toString();
	}
}
class CMD_S_RenewGGTime {
	Long re_time;// 

	String getJsonData() {
		JSONObject root = new JSONObject();
		root.put("command", "time_gg");
		root.put("time_gg", re_time);
		return root.toString();
	}
};
class CMD_S_AgentGG {
	String GGtype;
	String GGtxt;
	long timeGg;
	String getJsonData() {
		JSONObject root = new JSONObject();
		root.put("command", "showGG");
		root.put("type", GGtype);
		root.put("txt", GGtxt);
		root.put("timeGg", timeGg);
		return root.toString();
	}
};
class CMD_UserItem{
	HashMap<String,String> items = new HashMap<String,String>();
	String getJsonData() {
		JSONObject root = new JSONObject();
		root.put("command", "hall_get_useritem");
		root.put("txt", JsonUtils.serialize(items));
		return root.toString();
	}
};
class CMD_Buy_UserItem{
	int itemIndex;
	int getNum;
	int itemNum;
	int resultGem;
	int resultGold;
	String getJsonData() {
		JSONObject root = new JSONObject();
		root.put("command", "hall_buy_useritem");
		root.put("itemIndex",itemIndex);
		root.put("getNum",getNum);
		root.put("itemNum",itemNum);
		root.put("resultGem",resultGem);
		root.put("resultGold",resultGold);
		return root.toString();
	}
};
class CMD_UserAgentLevel{
	int level;
	int dwcLevel;
	String getJsonData(){
		JSONObject root = new JSONObject();
		root.put("command", "hall_get_agentlevel");
		root.put("level", level);
		root.put("dwcLevel", dwcLevel);
		return root.toString();
	}
};
class CMD_CancelBind{
	int result;
	int gem;
	String getJsonData(){
		JSONObject root = new JSONObject();
		root.put("command", "hall_cancel_bind");
		root.put("result", result);
		root.put("gem", gem);
		return root.toString();
	}
};
class CMD_DuiHuan_GemUU{
	int currGem;
	int currCoin;
	String getJsonData(){
		JSONObject root = new JSONObject();
		root.put("command", "hall_duihuan_gem_uu");
		root.put("currGem", currGem);
		root.put("currCoin", currCoin);
		return root.toString();
	}
};
class CMD_UU_Quit_BuChang{
	int success;
	int fzuid;
	int senderuid;
	int fzcoin;
	int sendercoin;
	int coin;
	String getJsonData(){
		JSONObject root = new JSONObject();
		root.put("command", "uu_buchang");
		root.put("success", success);
		root.put("fzuid", fzuid);
		root.put("senderuid", senderuid);
		root.put("fzcoin", fzcoin);
		root.put("sendercoin", sendercoin);
		root.put("coin", coin);
		return root.toString();
	}
};
class CMD_Use_Rank_InClub{
	int use;
	String getJsonData(){
		JSONObject root = new JSONObject();
		root.put("command", "hall_use_rank_inclub");
		root.put("use", use);
		return root.toString();
	}
};

class CMD_TodayCharge{
	int todaysum;
	int todaylimit;
	String getJsonData(){
		JSONObject root = new JSONObject();
		root.put("command", "hall_today_charge");
		root.put("todaysum", todaysum);
		root.put("todaylimit", todaylimit);
		return root.toString();
	}
};